#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > dpt_hf.info <<%EOF%
   dpt_hf
   -------
   Molecule:       HF in C2v
   Wave Function:  CCS, CCSD , CCSD(T) / cc-pCVDZ
   Test Purpose:   Analytical calculation of relativistic corrections
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > dpt_hf.mol <<%EOF%
BASIS
cc-pCVDZ
First-order relativistic corrections                                            
                                                                                
    2  0 2  X  Y      0.10E-14
        9.    1
F       0.0000000000000     0.0000000000000     0.0000000000000
        1.    1
H       0.0000000000000     0.0000000000000     1.7328000000000
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > dpt_hf.dal <<%EOF%
**DALTON
.RUN PROPERTIES
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
.DPTPOT
.KINENER
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-10
*CC INP
.CCS
.CCSD
.CC(T)
.PRINT
 4
.THRENR
1.0D-10
.THRLEQ
1.0D-07
*CCFOP
.ALLONE
.DPTECO
.2ELDAR
.BPH2OO
.BPH2SS
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >dpt_hf.check
cat >>dpt_hf.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#       !  First-order DPT corrections to the ground-state energy  !
#        Total first-order DPT correction:     -0.091121192
#        Total first-order DPT correction:     -0.091209180
#        Total first-order DPT correction:     -0.091215054
#        2-elec. Darwin term:      -0.005014784
#        2-elec. Darwin term:      -0.004790726
#        2-elec. Darwin term:      -0.004790367
#        BP2EOO:      0.001376950718
#        BP2EOO:      0.001109028427
#        BP2EOO:      0.001107867218

CRIT1=`$GREP "Total first-order DPT correction: * (\-0|\-)\.09112119...." $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=1
ERROR[1]="CCS first-order DPT correction not correct"

CRIT2=`$GREP "Total first-order DPT correction: * (\-0|\-)\.0912091[78]" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=1
ERROR[2]="CCSD first-order DPT correction not correct"

CRIT3=`$GREP "Total first-order DPT correction: * (\-0|\-)\.09121505" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=1
ERROR[3]="CCSD(T) first-order DPT correction not correct"

CRIT4=`$GREP "2-elec. Darwin term: * (\-0|\-)\.00501478" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
ERROR[4]="CCS 2-elec. Darwin term not correct"

CRIT5=`$GREP "2-elec. Darwin term: * (\-0|\-)\.00479072" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=1
ERROR[5]="CCSD 2-elec. Darwin term not correct"

CRIT6=`$GREP "2-elec. Darwin term: * (\-0|\-)\.00479036" $log | wc -l`
TEST[6]=`expr   $CRIT6`
CTRL[6]=1
ERROR[6]="CCSD(T) 2-elec. Darwin term not correct"

CRIT7=`$GREP "BP2EOO: * ( |0)\.0013769507" $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
ERROR[7]="CCS orbit-orbit correction not correct"

CRIT8=`$GREP "BP2EOO: * ( |0)\.0011090284" $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
ERROR[8]="CCSD orbit-orbit correction not correct"

CRIT9=`$GREP "BP2EOO: * ( |0)\.0011078672" $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
ERROR[9]="CCSD(T) orbit-orbit correction not correct"

PASSED=1
for i in 1 2 3 4 5 6 7 8 9
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%

chmod +x dpt_hf.check
#######################################################################
